package cn.dev.admin.holder;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * mq操作句柄
 *
 * @author zhb
 * @date 2020/10/27 10:22
 **/
@Slf4j
@Component
public class MqHolder {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * 发送消息到队列
     *
     * @author zhb
     * @date 2020/10/27 10:45
     * @param queueBeanName
     *            队列bean的名称
     * @param message
     *            消息
     * @return void
     */
    public void sendMessage(String queueBeanName, String message) {
//        if (StringUtils.isBlank(queueBeanName)) {
//            throw new RuntimeException("队列bean的名称不可为空");
//        }
//        if (StringUtils.isEmpty(message)) {
//            throw new RuntimeException("队列内容不可为空");
//        }

        rabbitTemplate.convertAndSend(queueBeanName, message);
    }

}
